package com.taotao.rest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.po.TbItem;
import com.taotao.po.TbItemDesc;
import com.taotao.po.TbItemParam;
import com.taotao.po.TbItemParamItem;
import com.taotao.pojo.TaotaoResult;
import com.taotao.rest.service.ItemService;

@Controller
@RequestMapping("/item")
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	@RequestMapping("/info/{itemId}")
	@ResponseBody
	public TaotaoResult getItemInfo(@PathVariable Long itemId){
		
		TbItem item = itemService.getItemById(itemId);
		return TaotaoResult.ok(item);
	}
	
	@RequestMapping("/desc/{itemId}")
	@ResponseBody
	public TaotaoResult getItemDesc(@PathVariable Long itemId){
		
		TbItemDesc itemDesc = itemService.getItemDescById(itemId);
		return TaotaoResult.ok(itemDesc);
	}
	
	@RequestMapping("/param/{itemId}")
	@ResponseBody
	public TaotaoResult getItemParam(@PathVariable Long itemId){
		
		TbItemParamItem itemParam = itemService.getItemParamById(itemId);
		return TaotaoResult.ok(itemParam);
	}
}
